package com.xjy.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjy.common.core.mybatisplus.core.ServicePlusImpl;
import com.xjy.common.core.page.PagePlus;
import com.xjy.common.core.page.TableDataInfo;
import com.xjy.common.utils.PageUtils;
import com.xjy.system.domain.ReportProjExpend;
import com.xjy.system.domain.bo.ReportProjExpendQueryBo;
import com.xjy.system.domain.vo.ReportProjExpendVo;
import com.xjy.system.mapper.ReportProjExpendMapper;
import com.xjy.system.service.IReportProjExpendService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 费用支出情况Service业务层处理
 *
 * @author mlb
 * @date 2022-03-17
 */
@Service
public class ReportProjExpendServiceImpl extends ServicePlusImpl<ReportProjExpendMapper, ReportProjExpend> implements IReportProjExpendService {

    @Override
    public ReportProjExpendVo queryById(Long projId){
        return getVoById(projId, ReportProjExpendVo.class);
    }

    @Override
    public TableDataInfo<ReportProjExpendVo> queryPageList(ReportProjExpendQueryBo bo) {
        PagePlus<ReportProjExpend, ReportProjExpendVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ReportProjExpendVo.class);
        return PageUtils.buildDataInfo(result);
    }

    @Override
    public List<ReportProjExpendVo> queryList(ReportProjExpendQueryBo bo) {
        return listVo(buildQueryWrapper(bo), ReportProjExpendVo.class);
    }

    private LambdaQueryWrapper<ReportProjExpend> buildQueryWrapper(ReportProjExpendQueryBo bo) {
        Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<ReportProjExpend> lqw = Wrappers.lambdaQuery();
        lqw.like(StrUtil.isNotBlank(bo.getName()), ReportProjExpend::getName, bo.getName());
        lqw.like(StrUtil.isNotBlank(bo.getSubjectName()), ReportProjExpend::getSubjectName, bo.getSubjectName());
        return lqw;
    }

}
